Skip to content

Implement basic card-based interception combat system#10

Merged
xbito merged 2 commits intomainfrom
feature/basic-interception-combat
Jul 7, 2025
Merged

Implement basic card-based interception combat system#10
xbito merged 2 commits intomainfrom
feature/basic-interception-combat

Conversation

@xbito
Copy link
Copy Markdown
Owner

@xbito xbito commented Jul 7, 2025

  • Defines BattleState and integrates it into GameState.
  • Adds InterceptConfirmationModal to initiate battles from WorldMap UFO clicks.
  • Implements BattleScreen UI with displays for vehicle/UFO status, player hand, and battle controls.
  • Implements card mechanics: deck setup, shuffling, drawing (including reshuffling discard), playing cards with energy costs.
  • Basic damage card effects and win/loss conditions are in place.
  • Rudimentary turn loop: player turn (play cards, end turn) -> basic UFO attack -> player draws card and refreshes energy.
  • Adds unit tests for card utility functions (shuffle, draw).

- Defines BattleState and integrates it into GameState.
- Adds InterceptConfirmationModal to initiate battles from WorldMap UFO clicks.
- Implements BattleScreen UI with displays for vehicle/UFO status, player hand, and battle controls.
- Implements card mechanics: deck setup, shuffling, drawing (including reshuffling discard), playing cards with energy costs.
- Basic damage card effects and win/loss conditions are in place.
- Rudimentary turn loop: player turn (play cards, end turn) -> basic UFO attack -> player draws card and refreshes energy.
- Adds unit tests for card utility functions (shuffle, draw).
@xbito xbito requested a review from Copilot July 7, 2025 15:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a basic card-based combat system triggered by intercepting UFOs, including data definitions, utility functions, UI components, and integration into the main app.

  • Adds new battle-related fields to the global game state (activeBattle, selected entities).
  • Overhauls card definitions with helper factories, consolidates into ALL_CARDS, and provides deck utilities with tests.
  • Introduces InterceptConfirmationModal and BattleScreen components, and hooks up battle initiation, card play, and turn flow in App.tsx.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/types.ts Added activeBattle, selectedVehicleForBattle, selectedUFOForBattle to GameState.
src/data/cards.ts Refactored card arrays using createEffect/createRequirement, consolidated into ALL_CARDS, and added getStarterDeck, shuffleDeck, and drawCards functions.
src/data/tests/cards.test.ts Added unit tests for deck shuffling, drawing, and starter deck generation.
src/components/InterceptConfirmationModal.tsx New modal component for choosing an interceptor before battle.
src/components/BattleScreen.tsx New battle UI showing statuses, hand, and controls.
src/App.tsx Integrated the interception/battle flow: state setup, handlers for playing cards and ending turns.
Comments suppressed due to low confidence (1)

src/types.ts:316

  • [nitpick] The new activeBattle, selectedVehicleForBattle, and selectedUFOForBattle fields lack comments. Consider adding docstrings to explain their expected usage and lifecycle.
  activeBattle?: BattleState | null;

newPlayerDiscard = drawResult.newDiscardPile;

// Replenish player energy (example: vehicle's energyPerTurn)
const playerMaxEnergy = prev.activeBattle.vehicleStatus.maxEnergy || 3;
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resets energy to maxEnergy each turn rather than using energyPerTurn. If intended, document it; otherwise, use vehicleStatus.energyPerTurn to refill energy.

Copilot uses AI. Check for mistakes.
break;
}
// Reshuffle discard pile into deck
console.log("Reshuffling discard pile into deck.");
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per logging guidelines, include a stage prefix, timestamp, and colorized output rather than a plain console.log. For example, use a helper that prepends [DRAW] [HH:MM:SS] and styles the message.

Copilot generated this review using guidance from repository custom instructions.
)}

<div className="flex justify-end space-x-3">
<button
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow the project's UI guidelines, add a relevant icon from lucide-react to the 'Launch Interceptor' and 'Cancel' buttons for better affordance.

Copilot generated this review using guidance from repository custom instructions.
const [currentTurnTransactions, setCurrentTurnTransactions] = useState<number>(0);


const handleInitiateBattle = useCallback((vehicle: Vehicle, ufo: UFO) => {
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler contains heavy battle-initialization logic. Consider extracting deck setup and initial BattleState construction into separate utility modules to keep App.tsx lean and maintainable.

Copilot generated this review using guidance from repository custom instructions.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@xbito xbito merged commit e2baf29 into main Jul 7, 2025
1 check passed
@xbito xbito deleted the feature/basic-interception-combat branch July 7, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants